package com.thinkgem.jeesite.quartz;

import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;


public class UserStatusJob {

    @Autowired
	private SystemService systemService;

	public void updateUserStatus(){
		System.out.println("User Status Update......................Start");
		User user = new User();
		user.setDelFlag(User.DEL_FLAG_NORMAL);
		List<User> list = systemService.findList(user);
		Date now = new Date();
		for(User tmp:list){
			if(tmp.getAvaliDate().before(now)){
				tmp.setDelFlag(User.DEL_FLAG_EXPIRED);
				tmp.setLoginFlag(Global.NO);
                systemService.updateUserSatus(tmp);
			}
		}
		System.out.println("User Status Update......................End");

	}
}
